package edu.biwu.response;

import jakarta.servlet.*;
import jakarta.servlet.http.*;
import jakarta.servlet.annotation.*;

import java.io.IOException;
import java.util.Date;

/**
 * HttpServletResponse中的方法：
 *  设置响应头：
 *      public void addHeader(String name , String value):可以添加响应头，一个响应头key可以对应多个value（或者说可以设置多个name相同的响应头）
 *      public void setHeader(String name ,String value):设置响应头，如果已经设置相同namen响应头，新的value值会覆盖老的value值（类似Hashmap）
 */
@WebServlet("/resp/demo02")
public class ResponseDemo02 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.addHeader("name" , "zhagnsan");
        response.addHeader("gender", "male");
        response.setDateHeader("Date",new Date().getTime());
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
